package com.example.service;

import com.example.dao.GoodsDao;
import com.example.model.Goods;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.sql.SQLException;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.when;

@ExtendWith(MockitoExtension.class)
class GoodsServiceTest3 {
    @Mock
    private GoodsDao goodsDao;
    @InjectMocks
    private GoodsService goodsService;

    @Test
    void getGoodsById() throws SQLException {
        //׼����������
        Goods expGoods = new Goods(21,"1231");
        //ģ����Ϊ
        when(goodsDao.getGoodsById(21)).thenReturn(expGoods);
        //ִ�в���
        Goods outGoods = goodsService.getGoodsById(21);
        //��֤���
        assertEquals("123123",outGoods.getName());

    }
}
